<template>
    <view class="msg-hint" v-if="showClone">
            <view class="icon">
                <image :src="icon"></image>
            </view>
            <view class="tip">
                <view class="tip-text">{{ title }}</view>
            </view>
        </view>
</template>

<script>
// components/numinput/numinput.js
export default {
    data() {
        return {
            timeClone: 0,
            showClone: false
        };
    }
    /**
     * 组件的属性列表
     */,
    props: {
        show: {
            type: Boolean,
            default: false
        },
        time: {
            type: Number,
            default: 3
        },
        title: {
            type: String,
            default: '添加成功，等你去结账'
        },
        icon: {
            type: String,
            default: ''
        }
    },
    /**
     * 组件的方法列表
     */
    methods: {
        intData() {
            var that = this;
            setTimeout(function () {
                var time = that.time;

                if (parseInt(time) > 0) {
                    time -= 1;
                    that.setData({
                        timeClone: time
                    });
                    that.intData();
                } else {
                    that.setData({
                        showClone: false,
                        timeClone: 3
                    });
                }
            }, 1000);
        }
    },
    watch: {
        show: {
            handler: function (data) {
                this.showClone = this.deepClone(this.show);
                //单个监听
                if (data == true) {
                    this.intData();
                }
            },

            immediate: true,
            deep: true
        },

        time: {
            handler: function (newVal, oldVal) {
                this.timeClone = newVal;
            },

            immediate: true
        }
    }
};
</script>
<style>
@import './index.css';
</style>
